<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>添加成员</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
	<%@include file="include/topbar.jsp"  %>

		<div class=" container" style="margin-top:60px;width:640px">
			 <ul class="breadcrumb" style="margin-bottom:0px;border-radius:3px 3px 0 0">		
				<li >
					<h4>添加员工</h4>
				</li>
			</ul>
			
		<form class=" wall"style="padding-left:160px">
			<div class="alert "id="alert" style="display:none;width:230px" >
			<a class="close" href="#">×</a> <strong id="help-msg"></strong>
			</div>
          <div class="control-group">
            <label for="input01" class="control-label">名字</label>
            <div class="controls">
              <input type="text" id="name" class="input-xlarge " name="name">
              <p class="help-block"></p>
            </div>
          </div>
         
         <div class="control-group">
            <label for="input01" class="control-label">密码</label>
            <div class="controls">
              <input type="password" id="pwd" class="input-xlarge " name="pwd">
              <p class="help-block"></p>
            </div>
          </div>
          
          <div >
            <button class="btn btn-primary"id="btn-primary" type="button">确认添加</button>
            <a href="emplist.jspx" class="btn btn-danger"">返回列表</a>
          </div>
        
      </form>

	</div>


		
		<script type="text/javascript">
		$(document).ready(function() {
			
			$(".close").click(function() {
				$("#alert").hide();
			});
			
			
		
			$("#btn-primary").click(function() {
				var name = $("#name").val();
				var pwd = $("#pwd").val();
				if (name.trim() == "" || pwd.trim() == "") {
					$("#alert").addClass("alert-error").show();
					$("#help-msg").text("用户名或者密码不能为空");
				} else{
					$.ajax({
						url:"addemp.jspx",
						type:"POST",
						data:{
							m:"add",
							name:name,
							pwd:pwd
						}
						}
					).done(function(msg){
						if(msg == 1){
							if($("#alert").hasClass("alert-error")){
								$("#alert").removeClass("alert-error");
							}
							$("#alert").addClass("alert-success").show();
							$("#help-msg").text("添加成功！");
							$("#name").val("");
							$("#pwd").val("");
						}else if(msg == 2){
							$("#alert").addClass("alert-error").show();
							$("#help-msg").text("用户名已经存在！");
							
						}
					});
				}
			});
		});
		</script>
</body>
</html>